<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import= "com.roadmap.common.BaseConst"%>
<%@ page import= "com.roadmap.struts.action.ActionConst"%>
<%@ page import= "com.roadmap.common.RdcResourceBundle"%>
<%@page import="com.roadmap.util.upload.PurikuraUpload"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String user_ssn_id = (String)request.getSession().getAttribute(ActionConst.Aspirant_Id_In_Session);

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/> 
<link href="res/css/layout.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/home.css" rel="stylesheet" type="text/css" media="all" />
<link href="res/css/widget.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="res/js/func.js"></script>
<script type="text/javascript" src="res/js/widget.js"></script>
<title>编辑个人头像 | <%=RdcResourceBundle.COMPANY_NAME %></title>

</head>

<body>
	<jsp:include page="/admin/myheader.jsp"></jsp:include>
	
	<div class="mainbody"><div class="myhome">
		<div class="left-part">
			<jsp:include page="/pagelet/userLinksPagelet.jsp"/>
			<jsp:include page="/pagelet/lifeLinksPagelet.jsp"/>
			<jsp:include page="/pagelet/friendLinksPagelet.jsp"/>
			<jsp:include page="/pagelet/msgLinksPagelet.jsp"/>
		</div>
		
		<div class="middle-part">
			<div class="purikura">
				<ul>
					<li style="width:200px; border-bottom:1px solid #E78F28;"><h3>当前头像</h3></li>
					<li style="width:200px;">头像默认显示为<%=RdcResourceBundle.COMPANY_NAME %></li>
					<li style="width:200px;">
						<img src="<%=BaseConst.PURIKURA_DIR_BIG%><%=user_ssn_id %>.gif?temp=<%=System.currentTimeMillis() %>" alt="<%=RdcResourceBundle.COMPANY_NAME %>"/>
					</li>
				</ul>
			</div>
			
			<div class="purikura">
				<ul>
					<li style="border-bottom:1px solid #E78F28;"><h3>修改头像</h3></li>
					<li>请选择新照片文件(后缀名为.jpg .jpeg)，大小不超过2M</li>
					<li>
						<form name="fileForm" action="purikura.do?v=upload" method="post" enctype="multipart/form-data" onsubmit="return verifyFile($('imageFile').value);">
							<input type="file" style="float:left;padding:3px;" name="imageFile"/>
							<input type="submit" style="float:left;" value="上传"/>
						</form>
					</li>
					<li>
					<%
						String param = request.getParameter("v");
						if(param != null && param.equalsIgnoreCase("upload")){
							try{
								PurikuraUpload upload = new PurikuraUpload();
								upload.initialize(pageContext);
								upload.setMaxFileSize(2066432);
								upload.upload();
								upload.save();
								response.sendRedirect(basePath + "purikura.do");
							}
							catch (Exception e){
								out.println("<div style='float:left;margin-top:20px;'>上传图片失败，请确定选择的图片符合要求</div>");
							}
						}
					%>
					</li>
				</ul>
			</div>
			
			
		</div>
		
		<div class="right-part"></div>
		</div><!-- myhome -->
		
		<div class="clear-div"></div>
	</div>
	
	
	
	<jsp:include page="/res/jsp/footer.jsp"></jsp:include>

<script type="text/javascript">
	window.onload = function (){
		PromptDialog.resize(250, 50);
		PromptDialog.relocate(80, 400);
	}
	
	function verifyFile(path){
		RDC.image.setPath(path);
		RDC.image.setMaxSize(2066432);
		if(!RDC.image.isValid()){
			PromptDialog.show("您选择的图片不符合要求，请重新选择");
			return false;
		}
		return true;
	}
	
	
</script>
</body>

</html>
